#ifndef __MYI2C_H__
#define __MYI2C_H__

#include "stm32f10x.h"

#define I2C_SCL_GPIO_CLK  RCC_APB2Periph_GPIOA
#define I2C_SCL_GPIO_PORT GPIOA
#define I2C_SCL_GPIO_PIN  GPIO_Pin_2

#define I2C_SDA_GPIO_CLK  RCC_APB2Periph_GPIOA
#define I2C_SDA_GPIO_PORT GPIOA
#define I2C_SDA_GPIO_PIN  GPIO_Pin_3

#define I2C_SCL_1()   GPIO_SetBits(I2C_SCL_GPIO_PORT,I2C_SCL_GPIO_PIN)
#define I2C_SCL_0()   GPIO_ResetBits(I2C_SCL_GPIO_PORT,I2C_SCL_GPIO_PIN)

#define I2C_SDA_1()   GPIO_SetBits(I2C_SDA_GPIO_PORT,I2C_SDA_GPIO_PIN)
#define I2C_SDA_0()   GPIO_ResetBits(I2C_SDA_GPIO_PORT,I2C_SDA_GPIO_PIN)

#define I2C_SDA_READ()         GPIO_ReadInputDataBit(I2C_SDA_GPIO_PORT,I2C_SDA_GPIO_PIN)

#define I2C_ADDR 			0XA0
#define I2C_READ_DIR 	0X01
#define I2C_WRITE_DIR 	0X00

void I2C_GPIO_Config(void);
uint8_t I2C_CHECK_DEVICE(uint8_t addr);
uint8_t I2C_WRITE_BYTE(uint8_t addr ,uint8_t data);
uint8_t I2C_READ_BYTE(uint8_t addr ,uint8_t *data);
uint8_t I2C_READ_BYTES(uint8_t addr ,uint8_t *data,uint16_t size);
uint8_t I2C_WRITE_BYTES(uint8_t addr ,uint8_t *data,uint16_t size);

#endif /* __MYI2C_H__ */
